home *** CD-ROM | disk | FTP | other *** search
- /////////////////
- // catalog.cpp //
- /////////////////
-
- #include "isam.h"
- #include <ctype.h>
-
- static struct cat {
- char *name;
- t_func func;
- } Catalog[] = { { "descwrds", descwrds },
- { NULL, NULL } };
-
- ///////////////////////
- // Catalog utilities //
- ///////////////////////
-
- int catalog_number (char *name)
- {
- int i = 0;
- while (Catalog[i].name) {
- if (!strcmp(nospace(name), Catalog[i].name))
- return i;
- i++;
- }
- return -1;
- }
-
- t_func cataloged_func(int f)
- {
- return Catalog[f].func;
- }
-
- /////////////////////////
- // Cataloged functions //
- /////////////////////////
-
- char * descwrds (char *r);
-
- char *descwrds (char *r)
- { // Extracts up to 20 - 7 letter words from desc field.
- // The description field starts at posn 37 and goes
- // on for 120 characters.
- static char keys[141];
- int i = 37, j = 0, k = 0;
-
- memset (keys, ' ', 140);
- while ((i < 157) && (k < 20)){
- while ((ispunct(r[i]) || isspace(r[i])) && i < 157)
- i++;
- while (!ispunct(r[i]) && !isspace(r[i]) && i < 157
- && j < 7)
- keys[(7 * k) + j++] = r[i++];
- while (!ispunct(r[i]) && !isspace(r[i]) && i < 157)
- i++;
- k++;
- j = 0;
- }
- keys[7 * k] = '\0';
- return keys;
- }
-
-